package com.diet263.utils;

import android.content.Context;
import android.content.Intent;
import android.nfc.NfcAdapter;

public class NFCUtils {

	private static NFCUtils instance = null;
	private NfcAdapter nfcAdapter;
	
	
	 /**
     * These values are matched in string arrays -- changes must be kept in sync
     */
	public static final int SECURITY_NONE = 0;
	public static final int SECURITY_WEP = 1;
	public static final int SECURITY_PSK = 2;
	public static final int SECURITY_EAP = 3;
	
	public static final long FLAG_PASSPOINT_NETWORK               = 0x0000000000000001;

	public static NFCUtils getNfcUtils(Context context) {
		if (instance == null) {
			instance = new NFCUtils();
			instance.nfcAdapter = NfcAdapter.getDefaultAdapter(context);
		}
		return instance;
	}

	private NFCUtils() {
	}

	public static boolean isNDEF(Intent intent) {
		return NfcAdapter.ACTION_NDEF_DISCOVERED.equals(intent.getAction());
	}

	public static boolean isTECH(Intent intent) {
		return NfcAdapter.ACTION_TECH_DISCOVERED.equals(intent.getAction());
	}

	public NfcAdapter initNfcAdapter() {
		return nfcAdapter;
	}

	/**
	 * 判断设备是否支持NFC
	 * 
	 * @return
	 */
	public boolean isSupportNFC() {
		return nfcAdapter != null;
	}

	/**
	 * 判断NFC功能是否开启
	 * 
	 * @return
	 */
	public boolean isNFCOn() {
		return nfcAdapter != null && nfcAdapter.isEnabled();
	}
}
